package com.example.zq.player.pager;

import android.graphics.drawable.Drawable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;


import com.example.zq.player.R;

import com.example.zq.player.linked_database_interface.Adapter.ShoppingPagerAdapter;
import com.example.zq.player.linked_database_interface.base.BaseFragment;
import com.example.zq.player.linked_database_interface.domain.ShoppingPager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zq on 2018/12/22.
 */

public class HomePager extends BaseFragment {

    private List<ShoppingPager> shoppingPagers = new ArrayList<>();
    private RadioButton rb_home_best_seller;
    private RadioButton rb_home_free_shopping;
    private RadioButton rb_home_wash_out_book;
    private RadioButton rb_home_new;
    private RadioButton rb_home_press;
    @Override
    protected int initLayout() {
        return R.layout.home_pager;
    }

    @Override
    protected void initView() {
        //修改RadioGroup图片的大小
        rb_home_best_seller = (RadioButton)getContentView().findViewById(R.id.rb_home_best_seller);
        Drawable drawable1 = getResources().getDrawable(R.drawable.home_best_seller);
        drawable1.setBounds(0,0,80,80);
        rb_home_best_seller.setCompoundDrawables(null,drawable1,null,null);

        rb_home_free_shopping = (RadioButton)getContentView().findViewById(R.id.rb_home_free_shopping);
        Drawable drawable2 = getResources().getDrawable(R.drawable.home_free_shopping);
        drawable2.setBounds(0,0,80,80);
        rb_home_free_shopping.setCompoundDrawables(null,drawable2,null,null);

        rb_home_wash_out_book = (RadioButton)getContentView().findViewById(R.id.rb_home_wash_out_book);
        Drawable drawable3 = getResources().getDrawable(R.drawable.home_wash_out_book);
        drawable3.setBounds(0,0,80,80);
        rb_home_wash_out_book.setCompoundDrawables(null,drawable3,null,null);

        rb_home_new = (RadioButton)getContentView().findViewById(R.id.rb_home_new);
        Drawable drawable4 = getResources().getDrawable(R.drawable.home_new);
        drawable4.setBounds(0,0,80,80);
        rb_home_new.setCompoundDrawables(null,drawable4,null,null);

        rb_home_press = (RadioButton)getContentView().findViewById(R.id.rb_home_press);
        Drawable drawable5 = getResources().getDrawable(R.drawable.home_press);
        drawable5.setBounds(0,0,80,80);
        rb_home_press.setCompoundDrawables(null,drawable5,null,null);

        //设置RecyclerView的监听事件
        RecyclerView recyclerView = (RecyclerView)getContentView().findViewById(R.id.rv_shopping_pager);
        recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2));
        ShoppingPagerAdapter adapter = new ShoppingPagerAdapter(shoppingPagers);
        recyclerView.setAdapter(adapter);
    }

    @Override
    protected void initData() {

        //传入数据到商品页面
       for(int i=0;i<10;i++){
           ShoppingPager shoppingPager1 = new ShoppingPager(R.drawable.product_59,"个人人格独立开发跟进反馈了估计",3);
           shoppingPagers.add(shoppingPager1);
       }
    }
}

